//
//  GLeftSortsViewController.m
//  项目B 重构腕表
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 GYD. All rights reserved.
//

#import "GLeftSortsViewController.h"
#import "AppDelegate.h"
#import "MagazineViewController.h"
#import "InformationViewController.h"
#import "SevendayViewController.h"

#import "VideoViewController.h"

#import "BrandViewController.h"


@interface GLeftSortsViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation GLeftSortsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"back.jpg"];
    [self.view addSubview:imageView];
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = self.view.bounds;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *Identifier = @"Identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont systemFontOfSize:20.0f];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    
    if (indexPath.row == 0) {
        cell.textLabel.text = @"腕表杂志";
    }else if (indexPath.row == 1){
        cell.textLabel.text = @"咨讯";
    }else if (indexPath.row == 2){
        cell.textLabel.text = @"七日热点";
    }else if (indexPath.row == 3){
        cell.textLabel.text = @"品牌维基";
    }else if (indexPath.row == 4){
        cell.textLabel.text = @"新品视频";
    }else if (indexPath.row == 5){
        cell.textLabel.text = @"我的";
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    if (indexPath.row == 0) {
        MagazineViewController *MagazineVC = [[MagazineViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView]; // 关闭抽屉
        
        [tempAppDelegate.mainNavigationController pushViewController:MagazineVC animated:NO];
    }
    if (indexPath.row == 1) {
        InformationViewController *InforVC = [[InformationViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView]; // 关闭抽屉
        
        [tempAppDelegate.mainNavigationController pushViewController:InforVC animated:NO];
    }
    if (indexPath.row == 2) {
        SevendayViewController *sevenVC = [[SevendayViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView]; // 关闭抽屉
        
        [tempAppDelegate.mainNavigationController pushViewController:sevenVC animated:NO];
        
    }

    if (indexPath.row == 4) {
        VideoViewController *VideoVC = [[VideoViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView]; // 关闭抽屉
        
        [tempAppDelegate.mainNavigationController pushViewController:VideoVC animated:NO];
    }

    if (indexPath.row == 3) {
        BrandViewController *brandVC = [[BrandViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView]; // 关闭抽屉
        
        [tempAppDelegate.mainNavigationController pushViewController:brandVC animated:NO];

        
    }
    
    
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
    return 180;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 180)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
